package cn.yh.nft.turbo.order.domain.validator;

import cn.yh.nft.turbo.order.validator.GoodsValidator;
import cn.yh.nft.turbo.order.validator.OrderCreateValidator;
import cn.yh.nft.turbo.order.validator.StockValidator;
import cn.yh.nft.turbo.order.validator.UserValidator;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @ClassName: OrderCreateValidatorConfig
 * @Author: 草莓爱上啵啵
 */
@Configuration
public class OrderCreateValidatorConfig {

    @Autowired
    private StockValidator stockValidator;

    @Autowired
    private GoodsValidator goodsValidator;

    @Autowired
    private UserValidator userValidator;

    @Bean("orderValidatorChain")
    public OrderCreateValidator orderValidatorChain(){
        userValidator.setNext(goodsValidator);
        goodsValidator.setNext(stockValidator);
        return userValidator;
    }
}
